<template>
  <div class="lm-uploader-wrapper">
    <div class="lm-uploader-imgelist">
      <div class="lm-uploader-container">
        <slot name="uploader-area">
          <div class="uploader-area">
            <lm-icon name="plus" size="20"></lm-icon>
            <div class="lm-uploader--text">
              将文件拖拽到此处，或<em>点击上传</em>
            </div>
          </div>
        </slot>
        <input type="file" class="lm-file__invisible" ref="file" />
      </div>
    </div>
    <div>
      <slot name="tip">
        <div class="lm-uploader--tip">只能上传jpg/png文件，且不超过500kb</div>
      </slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "LmUploader",
};
</script>

<style lang="scss" scoped>
.lm-file__invisible {
  display: none;
}

.lm-uploader-imagelist {
  display: flex;
}

.lm-uploader--tip {
  font-size: 12px;
  color: #606266;
  margin-top: 7px;
}

.lm-uploader--text {
  color: #606266;
  font-size: 14px;
  text-align: center;
  margin-top: 15px;

  em {
    color: #409eff;
    font-style: normal;
  }
}

// 预览图片列表
.preview-images-list {
  display: flex;
  margin: 0;
  padding: 0;
  list-style-type: none;

  li {
    width: 148px;
    height: 148px;
    margin-right: 10px;
    overflow: hidden;
    position: relative;

    &:hover {
      .preview-delete-icon {
        opacity: 1;
        background: rgba(0, 0, 0, 0.6);
        padding: 5px;
      }
    }

    // display: flex;
    // justify-content:center;
    // align-items: center;
    img {
      width: 100%;
      height: 100%;
      max-width: 100%;
    }
  }

  .preview-delete-icon {
    opacity: 0;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate3d(-50%, -50%, 0);
    color: #fff;
    font-size: 30px;
    cursor: pointer;
  }
}

.uploader-area {
  min-width: 148px;
  height: 148px;
  display: flex;
  padding: 0 10px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 1px dotted #ccc;
  font-size: 28px;
  cursor: pointer;
}
</style>